package com.azusa.xbiao.dao;

import com.azusa.xbiao.entity.Goods;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface GoodsDao extends JpaRepository<Goods,Integer>{

    /**
     * 查询最新发布的商品
     * @return
     */
    @Query(value = "select * from goods order by release_date desc limit 4",nativeQuery = true)
    List<Goods> selectNews();

    /**
     * 查询热销商品
     * @return
     */
    @Query(value = "select * from goods order by sales desc limit 4;",nativeQuery = true)
    List<Goods> selectHot();
}
